package reverse_linkedlist_loop

import (
	"algorithm/src/utils"
)

func ReverseLinkedList(node *utils.ListNode) *utils.ListNode {
	if node == nil || node.Next == nil {
		return node
	}
	cur := node
	var prev *utils.ListNode

	for cur != nil {
		cur.Next, prev, cur = prev, cur, cur.Next
	}
	return prev
}